#pragma once
using namespace std;

template<class T>
class MyArray
{
public:
	MyArray(int capacity)
	{
		this->capacity = capacity;
		arr = new T[capacity];
		size = 0;
	}
	MyArray(const MyArray& arr1)
	{
		if (arr != NULL)
		{
			delete[]arr;
			arr = NULL;
		}
		this->capacity = arr1->capacity;
		this->size = arr1->size;
		for (int i = 0;i < arr1->size;i++)
		{
			arr[i] = arr1[i];
		}
	}
	T& operator[](int detex)
	{
		return arr[detex];
	}
	~MyArray()
	{
		if (arr != NULL)
		{
			delete[] arr;
			arr = NULL;
		}
	}
	void PushBack(T val)
	{
		arr[size] = val;
		size++;
	}
	void PopBack()
	{
		if (size == 0)
		{
			return;
		}
		size--;
	}
	void print()
	{
		for (int i = 0;i < size;i++)
		{
			cout << arr[i] << " ";
		}
		cout << endl;
	}

private:

	int size;
	int capacity;
	T* arr;

};
